package com.boss.service.impl;

import com.boss.mappeer.UserMapper;
import com.boss.pojo.User;
import com.boss.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Slf4j
@Service
public class UserServiceImpl implements UserService {

    @Autowired
    private UserMapper userMapper;

    //根据用户名查询用户
    @Override
    public User findByUsername(String username) {
        User u= userMapper.findByUsername(username);
        return u;
    }

    @Override
    public void register(User user) {
        //插入用户
        userMapper.add(user.getUserName(), user.getPassword(),user.getName(),user.getRole(),user.getEmail(),user.getPhone());

    }

    //登录
    @Override
    public User login(User user) {
        return userMapper.getByUserNameAndPassword(user);
    }
}
